package com.xjl.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xjl.service.AdminService;
import com.xjl.service.impl.AdminServiceImpl;
/**
 * 处理用户删除管理员
 * @author JianLin_Xu
 *
 */
@WebServlet("/delete.do")
public class DeleteAdminServlet extends HttpServlet {
	AdminService as = new AdminServiceImpl();
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//设置请求编码格式
		req.setCharacterEncoding("utf-8");
		//设置响应编码格式
		resp.setContentType("text/html;utf-8");
		int adminid = Integer.parseInt(req.getParameter("adminid"));
		int index = as.DeleleAdmin(adminid);
		if(index==1){
			req.setAttribute("flag", "删除成功！");
			
		}else if(index==-1){
			req.setAttribute("flag", "查无此人！");
		}else{
			req.setAttribute("flag", "删除失败，请稍后再试！");
		}
		req.getRequestDispatcher("selectall.do").forward(req, resp);
	}
}
